<template>
  <div class="modal_table_only">
    <ProTable
      ref="tableRef"
      :fetchListApi="_pushLog"
      :columns="columns"
      row-key="configPushTotalId"
      hide-search
    >
      <template #operation="{ record }">
        <b-button icon="edit" type="link" @click="handleCheck(record)"
          >查看记录</b-button
        >
      </template>
    </ProTable>
  </div>
</template>

<script setup lang="tsx">
import { computed, ref } from 'vue';
import { message } from 'ant-design-vue';
import { ProTable, ProTableProps } from '@/components/ProTable/index';
import { pushDataLog } from '@/api/push';

defineOptions({
  name: 'PushRecord',
});

interface Props {
  pageData: any;
}
const props = defineProps<Props>();

const tableRef = ref();
const _pushLog = (params: any) => {
  return pushDataLog(props.pageData.dataManageId, { ...params });
};
const columns = computed<ProTableProps['columns']>(() => [
  {
    title: '推送时间',
    dataIndex: 'pushTime',
  },
  {
    title: '推送总数',
    dataIndex: 'totalCount',
  },
  {
    title: '推送成功数',
    dataIndex: 'successCount',
  },
  {
    title: '推送失败数',
    dataIndex: 'failCount',
    customRender({ record, text }) {
      return (
        <b-button
          type='link'
          onClick={() => {
            handleCheck(record, '0');
          }}
        >
          {text}
        </b-button>
      );
    },
  },
  {
    title: '推送人',
    dataIndex: 'pushBy',
  },
  {
    title: '操作',
    dataIndex: 'operation',
    fixed: 'right',
    width: 150,
  },
]);

const emit = defineEmits(['handleCheck']);
const handleCheck = async (record: any, sta?: any) => {
  emit('handleCheck', record, sta);
};
</script>
